export const crudOptions = (vm) => {
  return {
    options: {
      tableType: 'vxe-table',
      rowKey: true,
      rowId: 'id',
      height: '100%', // 表格高度100%, 使用toolbar必须设置
    },
    viewOptions: {
      componentType: 'form'
    },
    formOptions: {
      appendToBody: true, // 子表格必须 否则弹出对话框无法显示最顶层
      defaultSpan: 24, // 默认的表单 span
      width: '35%'
    },
    rowHandle: {
      width: 120,
      fixed: 'right',
      view: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Retrieve')
        }
      },
      edit: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Update')
        }
      },
      remove: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Delete')
        }
      },
    },
    indexRow: { // 或者直接传true,不显示title，不居中
      title: '序号',
      align: 'center',
      width: 70
    },
    columns: [
      {
        title: 'ID',
        key: 'id',
        show: false,
        form: {
          disabled: true
        }
      },
      {
        title: '用户ID',
        key: 'users_id',
        width: 80,
        search: {
          disabled: false,
          component: {
            placeholder: '请输入用户ID',
            clearable: true
          }
        },
        type: 'input'
      },
      {
        title: '昵称',
        key: 'openname',
        width: 100,
        search: {
          disabled: false,
          component: {
            placeholder: '请输入用户昵称',
            clearable: true
          }
        },
        type: 'input'
      },
      {
        title: '第三方应用',
        key: 'platform',
        width: 90,
        search: {
          disabled: true,
          component: {
            placeholder: '请输入第三方应用',
            clearable: true
          }
        },
        type: 'input'
      }, {
        title: '第三方OpenId',
        key: 'open_id',
        width: 130,
        search: {
          disabled: true
        },
        type: 'input'
      },
      {
        title: '第三方UnionId',
        key: 'union_id',
        width: 150,
        search: {
          disabled: true
        },
        type: 'input'
      },
      {
        title: 'IP',
        key: 'login_ip',
        width: 120,
        search: {
          disabled: true
        },
        type: 'input'
      },
      {
        title: '国家',
        key: 'country',
        width: 80,
        search: {
          disabled: true
        },
        type: 'input'
      },
      {
        title: '省份',
        key: 'province',
        width: 100,
        search: {
          disabled: true
        },
        type: 'input'
      },
      {
        title: '城市',
        key: 'city',
        width: 100,
        search: {
          disabled: true
        },
        type: 'input'
      },
      {
        title: '区县',
        key: 'district',
        width: 100,
        search: {
          disabled: true
        },
        type: 'input'
      },
      {
        title: '详细地址',
        key: 'address',
        minWidth: 300,
        show: false,
        search: {
          disabled: true
        },
        type: 'input'
      }, {
        title: '头像',
        key: 'avatar',
        type: 'avatar-cropper',
        width: 60,
        align: 'left',
        form: {
          component: {
            props: {
              elProps: { // 与el-uploader 配置一致
                multiple: false,
                limit: 1 // 限制5个文件
              },
              sizeLimit: 500 * 1024 // 不能超过限制
            },
            span: 24
          },
          helper: '限制文件大小不能超过500k'
        }
      }
    ].concat(vm.commonEndColumns({ show_create_datetime: false }))
  }
}
